package com.example.demo03_mvm.view;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.SearchView;
import androidx.fragment.app.Fragment;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.example.demo03_mvm.R;
import com.example.demo03_mvm.databinding.FragmentHomeBinding;
import com.example.demo03_mvm.viewmodel.MainViewModel;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link HomeFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class HomeFragment extends BaseFragment<MainViewModel, FragmentHomeBinding> {
    public static HomeFragment newInstance() {

        Bundle args = new Bundle();

        HomeFragment fragment = new HomeFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int inflateLayout() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initData() {
        vm.initAdapter(db,this);
        if(NetworkUtils.isConnected()) {//有网，请求网络数据
            vm.getGoodsList(1, this, db);
        }else{//无网，读取本地数据
            vm.getGoodsBYNoNet(this, db);
        }

    }

    @Override
    protected void initView() {

    }
}